package week8;
class Person {
}
class Student extends Person {
}
class Postgraduate extends Student {
}
class Animal {
}
public class Ex_instanceOf {
    public static void main(String[] args) {
        instanceofTest(new Postgraduate());
    }
    public static void instanceofTest(Person p) {
        //if(p instanceof Animal)System.out.println("p是类Animal的实例");
        if (p instanceof Postgraduate) System.out.println("p是类Postgraduate的实例");
        if (p instanceof Person) System.out.println("p是类Person的实例");
        if (p instanceof Student) System.out.println("p是类Student的实例");
        if (p instanceof Object) System.out.println("p是类Object的实例");

    }
}